package com.runen.infinitemovement.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.runen.infinitemovement.R;
import com.runen.infinitemovement.activity.ColumnActivity;
import com.runen.infinitemovement.model.entity.CollageInfoEntity;
import com.runen.infinitemovement.model.entity.InformationListEntity;
import com.runen.infinitemovement.tool.GlideUtils;
import com.runen.infinitemovement.widget.imageview.RoundedCornersImage;
import com.umeng.commonsdk.debug.I;

import java.util.List;

public class ConsultAdapter extends BaseQuickAdapter<InformationListEntity, BaseViewHolder>implements LoadMoreModule {
    private Context context;

    public ConsultAdapter(Context context) {
        super(R.layout.item_consult);
        this.context = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, InformationListEntity item) {
        TextView tv_consult_click = helper.getView(R.id.tv_consult_click);
        TextView tv_company_activity = helper.getView(R.id.tv_company_activity);
        TextView tv_see_num = helper.getView(R.id.tv_see_num);
        TextView tv_comment_num = helper.getView(R.id.tv_comment_num);
        TextView tv_hot = helper.getView(R.id.tv_hot);
        RoundedCornersImage rci_cover = helper.getView(R.id.rci_cover);
        tv_company_activity.setText(item.title);
        tv_see_num.setText(item.readNumber + "浏览");
        tv_comment_num.setText(item.commentNumber + "评论");
        GlideUtils.loadImage(context, item.cover+"?x-oss-process=image/resize,m_fill,w_144,h_144", rci_cover);
        tv_consult_click.setText(item.subjectName);
        if (item.recommend == 1) {
            tv_hot.setVisibility(View.VISIBLE);
        }
        tv_consult_click.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, ColumnActivity.class);
                intent.putExtra("subjectId", item.subjectId);
                context.startActivity(intent);
            }
        });
    }
}
